﻿package mortal.game.view.copy
{
    import Message.DB.Tables.*;
    import Message.Public.*;
    import flash.utils.*;
    import mortal.game.resource.*;
    import mortal.game.view.copy.ChallengeCopy.*;
    import mortal.game.view.copy.GroupTowerCopy.*;
    import mortal.game.view.copy.defenseCopy.*;
    import mortal.game.view.copy.escort.*;
    import mortal.game.view.copy.expCopy.*;
    import mortal.game.view.copy.guildCopy.*;
    import mortal.game.view.copy.guildDefenseCopy.*;
    import mortal.game.view.copy.petBreak.*;
    import mortal.game.view.copy.sixBoss.*;
    import mortal.game.view.copy.sunbathCopy.*;
    import mortal.game.view.copy.towerCopy.*;
    import mortal.game.view.copy.treasureHunt.*;
    import mortal.game.view.copy.uniqueBoss.*;
    import mortal.game.view.copy.wine.*;
    import mortal.game.view.copy.worldBoss.*;

    public class CopyCache extends Object
    {
        public var escort:EscortCopyCache;
        public var guildCopy:GuildCopyCache;
        public var defenseCopy:DefenseCopyCache;
        public var challengCopy:ChallengeCopyCache;
        public var petBreakCopy:PetBreakCopyCache;
        public var tower:TowerCache;
        public var worldBoss:WorldBossCache;
        public var sunbath:SunbathCopyCache;
        public var wineParty:WinePartyCopyCache;
        public var treasureHunt:TreasureHuntCache;
        public var guildDefence:GuildDefenseCopyCache;
        public var sixBoss:SixBossCache;
        public var groupTower:GroupTowerCahe;
        public var uniqueBoss:UniqueBossCache;
        public var expCopy:ExpCopyCache;
        private var _copyInfo:TCopy;
        public var quitTime:int = -1;
        public var guideWhenLeaveCopy:int = -1;
        private var _enterCounts:Dictionary;
        private var _extraEnterCounts:Dictionary;
        public var copyFirstBloodDic:Dictionary;

        public function CopyCache()
        {
            this._enterCounts = new Dictionary();
            this._extraEnterCounts = new Dictionary();
            this.copyFirstBloodDic = new Dictionary();
            this.initCaches();
            return;
        }// end function

        private function initCaches() : void
        {
            this.escort = new EscortCopyCache();
            this.guildCopy = new GuildCopyCache();
            this.defenseCopy = new DefenseCopyCache();
            this.challengCopy = new ChallengeCopyCache();
            this.petBreakCopy = new PetBreakCopyCache();
            this.tower = new TowerCache();
            this.worldBoss = new WorldBossCache();
            this.sunbath = new SunbathCopyCache();
            this.wineParty = new WinePartyCopyCache();
            this.treasureHunt = new TreasureHuntCache();
            this.guildDefence = new GuildDefenseCopyCache();
            this.sixBoss = new SixBossCache();
            this.groupTower = new GroupTowerCahe();
            this.uniqueBoss = new UniqueBossCache();
            this.expCopy = new ExpCopyCache();
            return;
        }// end function

        public function set copyInfo(param1:TCopy) : void
        {
            this._copyInfo = param1;
            return;
        }// end function

        public function get copyInfo() : TCopy
        {
            return this._copyInfo;
        }// end function

        public function get isInCopy() : Boolean
        {
            return this._copyInfo != null;
        }// end function

        public function updateEnterCounts(param1:Dictionary) : void
        {
            this._enterCounts = param1;
            return;
        }// end function

        public function updateExtraEnterCounts(param1:Dictionary) : void
        {
            this._extraEnterCounts = param1;
            return;
        }// end function

        public function getTodayEnterTimes(param1:int) : int
        {
            var _loc_2:* = this._enterCounts[param1];
            if (_loc_2 == null)
            {
                return 0;
            }
            return _loc_2.enterNum;
        }// end function

        public function getGroupCopyEnterNum(param1:int) : int
        {
            var _loc_2:TCopy = null;
            var _loc_3:int = 0;
            var _loc_4:String = null;
            for (_loc_4 in this._enterCounts)
            {
                
                _loc_2 = CopyConfig.instance.getCopyInfoByCode(int(_loc_4));
                if (_loc_2 && _loc_2.type == param1)
                {
                    _loc_3 = _loc_3 + (this._enterCounts[_loc_4] as SPlayerCopy).enterNum;
                }
            }
            return _loc_3;
        }// end function

        public function getCopyExtraEnterNumByGroup(param1:int) : int
        {
            var _loc_2:int = 0;
            var _loc_3:String = null;
            for (_loc_3 in this._extraEnterCounts)
            {
                
                if (int(_loc_3) == param1)
                {
                    _loc_2 = this._extraEnterCounts[_loc_3];
                    break;
                }
            }
            return _loc_2;
        }// end function

        public function getGroupCopyEnterNumByGroup(param1:int) : int
        {
            var _loc_2:TCopy = null;
            var _loc_3:int = 0;
            var _loc_4:String = null;
            for (_loc_4 in this._enterCounts)
            {
                
                _loc_2 = CopyConfig.instance.getCopyInfoByCode(int(_loc_4));
                if (_loc_2 && _loc_2.group == param1)
                {
                    _loc_3 = _loc_3 + (this._enterCounts[_loc_4] as SPlayerCopy).enterNum;
                }
            }
            return _loc_3;
        }// end function

    }
}
